using Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Domain
{
    /// <summary>
    /// 分页信息   
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    [Serializable]
    public class PageInfo<T> where T : class
    {
        /// <summary>
        /// 页面索引
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 页面大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总记录条数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页面数据
        /// </summary>
        public List<T> EntityArray { get; set; }

        /// <summary>
        /// 页面构造器
        /// </summary>
        public PageInfo() { }

        /// <summary>
        /// 分页信息
        /// </summary>
        /// <param name="totalCount">所有条目</param>
        /// <param name="entityArray">分页数据</param>
        public PageInfo(int totalCount, IEnumerable<T> entityArray)
        {
            this.TotalCount = totalCount;
            this.EntityArray = entityArray.ToList();
        }

       
        /// <summary>
        /// 总记录条目
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("TotalCount={0}", this.TotalCount);
        }
    }
}
